/*
####################################################################################################
SCUMM Trigger
This Class Represents a trigger. Realizes a function when the mainActor hits with it.
####################################################################################################
*/

class SCUMMCore.SCUMMTrigger{
	private var mcTrigger:MovieClip;
	private var mcActor:MovieClip;
	
	public function doTriggerAction(){
			trace("triggerAction");
			//overwrite this with the code, someting like
 			//_root.gotoAndPlay("someFrame");
	}
	public function SCUMMTrigger(pmcTrigger:MovieClip, pmcActor:MovieClip){
		/*
		if(pmcTrigger == undefined){
			throw new Error("SCUMMTrigger - Error: The sprite of the trigger can't be null");
		}
		if(pmcActor == undefined){
			throw new Error("SCUMMTrigger - Error: The sprite of the Actor can't be null");
		}
		*/
		this.mcTrigger = pmcTrigger;
		this.mcActor = pmcActor;
		//This is the loop of the trigger. 
		var oTriggerReference = this;
		//Check if the actor hits the trigger
 		this.mcTrigger.onEnterFrame = function() {
 			if(oTriggerReference.mcTrigger.hitTest(oTriggerReference.mcActor)){
 				oTriggerReference.doTriggerAction();
 			}
 		};		
 		//this is very important, because "this" is not visible from
		//functions defined in constructor.
 		var oSelfReference:SCUMMTrigger =  this;
 		this.mcTrigger.onRollOver = function(){
 			_global.ActionBar.setOActionParameter1(oSelfReference);
 		};
 		this.mcTrigger.onRollOut = function(){
 			_global.ActionBar.setOActionParameter1(undefined);
 		};
	}
}